package com.artPreter.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;

import com.artPreter.pojo.other.HttpRealData;
import com.artPreter.pojo.vos.page.InputDevicePageVO;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 即时温度记录表
 * </p>
 *
 * @author Jarvis_He
 * @since 2024-04-23
 */
@Getter
@Setter
@TableName("jv_temp_hum_memo")
public class TempHumMemo implements Serializable {

    private static final long serialVersionUID = 1L;

    //ID")


    //创建时间")
    @TableField("create_time")
    private Long createTime;

    //排序")
    @TableField("sort")
    private Integer sort;

    //备注")
    @TableField("remarks")
    private String remarks;

    //1启用")
    @TableField("status")
    private Integer status;

    //温度数值")
    @TableField("temp_val")
    private double tempVal;

    //湿度数值")
    @TableField("hum_val")
    private double humVal;

    //是否超出阀值")
    @TableField("is_over")
    private Integer isOver;

    //区域id")
    @TableField("position")
    private String position;

    //楼层id")
    @TableField("floor")
    private String floor;

    //房间id")
    @TableField("room")
    private String room;

    //温控设备id")
    @TableField("device_id")
    private String deviceId;

    //阀值")
    @TableField("over_value")
    private String overValue;

    @TableField("over_value2")
    private String overValue2;

    @TableField(exist = false)
    private String chid;

    public TempHumMemo() {
    }

    public TempHumMemo(HttpRealData realData, InputDevicePageVO device) {
        // 创建时间
        Long timeLong = System.currentTimeMillis()/1000;
        this.createTime = timeLong;
        // 备注
        this.remarks = device.getRemarks();
        // 区域uuid
        this.position = device.getPosition();
        // 楼层uuid
        this.floor = device.getFloor();
        // 库房uuid
        this.room = device.getRoom();
        // 设备uuid
        this.deviceId = device.getUuid();
        if(realData.getChname().equals("温度")){
            // 温度
            this.tempVal = Double.parseDouble(realData.getCurvalue());
            if(this.tempVal>Double.parseDouble(device.getOverValue())){
                this.overValue = "1";
            }else{
                this.overValue = "0";
            }
        }else if(realData.getChname().equals("湿度")){
            // 湿度
            this.humVal = Double.parseDouble(realData.getCurvalue());
            if(this.humVal>Double.parseDouble(device.getOverValue2())){
                this.overValue2 = "1";
            }else{
                this.overValue2 = "0";
            }
        }
        this.chid = realData.getSbid();
    }
}
